<extend name="Base/common"/>
<block name="css">

</block>
<block name="body">
    <header class="mui-bar mui-bar-nav dl_header">
        <a href="javascript:history.back();" id="close" class="iconfont icon-guanbi dl_closed"></a>
        <a href="{:U('Agent/index')}" class="dl_fast">非自主报名</a>
    </header>
    <div class="mui-content" id="container_wrap">
        <div  style="display: -webkit-box;-webkit-box-orient: horizontal;-webkit-box-pack: center;overflow: hidden;">
            <img src="__PUBLIC__/Home/images/index/xglogo.png" class="img-responsive center-block logo"/>
        </div>
        <form class="form-horizontal dl_form" id="form_one">
            <input type="hidden" value="{$data['id']}" name="id">
            <div class="form-group form-line-input" style="margin-top:10px;">
                <input type="text" class="form-control" value="{$data.name}" id="name"  name="name">
                <label for="name" <notempty name="data['name']">style="top: 0;font-size: 1.3rem;"</notempty>>姓名</label>
            </div>
            <div class="form-group form-line-input has-success" style="margin-top:10px;">
                <input type="text" class="form-control" value="{$data.ID_number}" id="ID_number"  name="ID_number">
                <label for="ID_number" <notempty name="data['ID_number']">style="top: 0;font-size: 1.3rem;"</notempty>>身份证</label>
            </div>
            <div class="form-group form-line-input has-success" style="margin-top:10px;">
                <input type="text" class="form-control" value="{$data.mobile}" id="mobile" name="mobile">
                <label for="mobile" <notempty name="data['mobile']">style="top: 0;font-size: 1.3rem;"</notempty>>联系电话</label>
            </div>
            <div class="form-group form-line-input has-success" style="margin-top:10px;">
                <select id="major" class="form-control edited" name="major">
                    <volist name="major" id="vo">
                        <option value="{$vo.id}">{$vo.title}</option>
                    </volist>
                </select>
                <label for="major">感兴趣专业</label>
            </div>

            <div class="form-group form-line-input has-success" style="margin-top:10px;">
                <input type="text" class="form-control" value="{$data.home_address}" id="home_address" name="home_address">
                <label for="home_address" <notempty name="data['home_address']">style="top: 0;font-size: 1.3rem;"</notempty>>家庭住址</label>
            </div>
            <div class="form-group form-line-input has-success" style="margin-top:10px;">
                <input type="text" class="form-control" value="{$data.school}" id="school"  name="school">
                <label for="school"  <notempty name="data['school']">style="top: 0;font-size: 1.3rem;"</notempty>>毕业学校</label>
            </div>

            <a href="javascript:" id="add_btn" class="btn btn-mini btn-primary common_btn">提交</a>

        </form>

    </div>


</block>

<block name="script">
    <script>

        $("#add_btn").click(function(){
            var $name=$("input[name=name]").val(),
                $ID_number=$("input[name=ID_number]").val(),
                $mobile=$("input[name=mobile]").val();

            if($name==''){
                $.dialog({
                    content : '请填写名字',
                    title: "alert",
                    time : 1000
                });
                return false;
            }

            if($ID_number==''){
                $.dialog({
                    content : '请填写身份证号',
                    title: "alert",
                    time : 1000
                });
                return false;
            }

            if($mobile==''){
                $.dialog({
                    content : '请填写联系电话',
                    title: "alert",
                    time : 1000
                });
                return false;
            }

            if($mobile!=''){
                var m_re = /^1\d{10}$/
                if (!m_re.test($mobile)) {
                    $.dialog({
                        content : '手机格式错误',
                        title: "alert",
                        time : 1000
                    });
                    return false;
                }
            }

            if($ID_number!=''){
                var reg = /^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;
                if(reg.test($ID_number)){
                    $.post('{:U("Agent/checkfield")}', {ID_number:$ID_number,type:1}, function(data){
                        if(data.status){
                            $.dialog({
                                content : data.info,
                                title: "alert",
                                time : 1000
                            });
                        }else{
                            $.post('{:U("Student/saveData")}', $("form").serialize(), function(data){
                                if(data.status){
                                    $.dialog({
                                        content : data.info,
                                        title: "ok",
                                        time : 1000
                                    });
                                    setTimeout(function () {
                                        location.reload();
                                    },1000);
                                }else{
                                    $.dialog({
                                        content : data.info,
                                        title: "alert",
                                        time : 1000
                                    });
                                }
                            });
                        }
                    });
                }else{
                    $.dialog({
                        content : '身份证号格式不正确',
                        title: "alert",
                        time : 1000
                    });
                    return false;
                }
            }




        });
    </script>
</block>